package com.taijia.chapter8;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * FileInputStreamTest
 * 
 * @author taijia
 * @since 2014年11月25日
 *
 */
public class FileInputStreamTest {
	public static void main(String[] args) {
		int b = 0;
		FileInputStream fis = null;
		try {
			fis = new FileInputStream("E:/myeclipse2014/Workspaces/2014/msb_basic/src/com/taijia/chapter8/FileInputStreamTest.java");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			System.exit(-1);
		}
		long num=0;
		try {
			while ((b=fis.read()) != -1) {
				System.out.print((char)b);
				num++;
			}
			System.out.println();
			System.out.println("共读取了： "+ num + "个字节");
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(-1);
		} finally {
			try {
				fis.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
